/*
 * Copyright (C) 2015 yixun All Rights Reserved.
 * 
 * BankNoController.java
 */
package com.yixun.qfbao.controller;

import java.io.IOException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.alibaba.fastjson.JSONObject;
import com.yixun.common.controller.BaseController;
import com.yixun.common.exception.YIXUNUNCheckedException;
import com.yixun.common.page.Page;
import com.yixun.common.page.PageUtil;
import com.yixun.qfbao.controller.vo.BankNoVo;
import com.yixun.qfbao.model.BankNo;
import com.yixun.qfbao.model.dto.BankNoDto;
import com.yixun.qfbao.service.BankNoService;

/**
 * [文件名称]<br>
 * BankNoController.java<br>
 * <br>
 * [文件描述]<br>
 * 银行联行号 Controller<br>
 * <br>
 * [修改记录]<br>
 * 2015-11-07 10:46:37 创建 陶俊代码生成器<br>
 * 
 * @author 陶俊代码生成器
 * @version 1.00
 */
@Controller
@RequestMapping("/jr/bankno")
public class BankNoController extends BaseController {
	@Autowired
	private BankNoService mservice;
	private static Logger log = Logger.getLogger(BankNoController.class);
	
	/**
	 * 获取银行联行号
	 * @param entity
	 * @param response
	 * @return
	 * @throws IOException
	 */
	@RequestMapping("/getBankNo")
	public String getBankNo(BankNoVo bankNoVo, HttpServletRequest request,HttpServletResponse response) throws IOException{
		String data ="";
		Page<BankNo> pageModel = null;
		try {
			int page = Integer.parseInt(request.getParameter("page"));
			int pageSize = Integer.parseInt(request.getParameter("rows"));
			String keyword = request.getParameter("keyword")==null?"":request.getParameter("keyword");
			BankNoDto bankNoDto = new BankNoDto();
			bankNoDto.setBankNo(keyword.trim());
			bankNoDto.setBankName(keyword.trim());
			bankNoDto.setBankAddress(keyword.trim());
			bankNoDto.setIsValid("0");
			pageModel = mservice.getPageModel(bankNoDto,PageUtil.begin(page,pageSize),pageSize);
			data = JSONObject.toJSONString(pageModel);
		}catch (YIXUNUNCheckedException e) {
			log.error("创建失败",e);
		}catch (Exception e) {
			log.error("创建失败",e);
		}
		response.getWriter().write(data);
		return null;
	}
}
